package com.sangeng.controller;


import com.sangeng.domain.ResponseResult;
import com.sangeng.entity.Article;
import com.sangeng.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 文章表 前端控制器
 * </p>
 *
 * @author lz
 * @since 2024-07-10
 */
@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    IArticleService articleService;

    // 写一个测试方法
    @RequestMapping("/test")
    public List<Article> test() {
        return articleService.list();
    }


    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList() {
        return articleService.hotArticleList();
    }


    @GetMapping("/articleList")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
        return articleService.articleList(pageNum,pageSize,categoryId);
    }

    // 详情
    @GetMapping("/{id}")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){
        return articleService.getArticleDetail(id);
    }
}
